class UserSessionsController < ApplicationController
  before_filter :init, :oly => :new
  before_filter :require_no_user, :only => [:new, :create]
  before_filter :require_user, :only => :destroy
  def new
    @user_session = UserSession.new
    @page["name"] = "login"
    @page["styles"] << "roundmenuUI"
    @page["meta"] = false
  end

  def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = I18n.t "site.message.login_successful"
      redirect_back_or_default root_path
    else
      @page["name"] = "login"
      @page["styles"] << "roundmenuUI"
      @page["meta"] = false
      render :action => :new
    end
  end

  def destroy
    current_user_session.destroy
    flash[:notice] = I18n.t "site.message.logout_successful"
    redirect_to root_path
  end
end
